﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace ShootEm.Components
{
    public class Movable : Microsoft.Xna.Framework.DrawableGameComponent
    {
        protected Texture2D texture;
        string textureStr;
        public int x;
        public int y;
        protected int vitesse;

        public Movable(ShootEm game, int x, int y, string texture, int vitesse)
            : base(game)
        {
            this.x = x;
            this.y = y;
            this.textureStr = texture;
            this.vitesse = vitesse;

        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here
            this.texture = this.Game.Content.Load<Texture2D>(textureStr);
            base.Initialize();
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            // The avatar follows the mouse position
            /* MouseState mouseState = Mouse.GetState();
             this._x = mouseState.X;
             this._y = mouseState.Y;*/

            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {



            ((ShootEm)this.Game).spriteBatch.Begin();
            ((ShootEm)this.Game).spriteBatch.Draw(this.texture, new Vector2(this.x, this.y), Color.White);
            ((ShootEm)this.Game).spriteBatch.End();
            base.Draw(gameTime);
        }
    }
}